package com.terrace.db.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.terrace.db.constant.DBType;
import com.terrace.db.system.dao.LangDao;
import com.terrace.db.system.mapper.entity.Lang;
import com.terrace.db.system.service.LangService;
import com.terrace.core.mybatis.entity.Pagination;
import com.terrace.core.mybatis.plugin.pagination.PaginationHelper;
import com.terrace.core.spring.datasource.annotation.DataSource;
import com.terrace.core.spring.ehcache.annotation.EhCacheEvict;
import com.terrace.core.spring.ehcache.annotation.EhCacheable;

@Service
@Transactional
@DataSource(name = DBType.ADMIN)
public class LangServiceImpl implements LangService {
	
	@Autowired
	private LangDao langDao;

	@Override
	@EhCacheEvict(key = "selectLangContentByKey")
	public int saveLangSelective(Lang lang) {
		return langDao.saveLangSelective(lang);
	}

	@Override
	@EhCacheEvict(key = "selectLangContentByKey")
	public int deleteLangById(Integer langId) {
		return langDao.deleteLangById(langId);
	}

	@Override
	@EhCacheEvict(key = "selectLangContentByKey")
	public int updateLangByIdSelective(Lang lang) {
		return langDao.updateLangByIdSelective(lang);
	}

	@Override
	public Lang selectLangById(Integer langId) {
		return langDao.selectLangById(langId);
	}

	@Override
	public Pagination<Lang> selectLangForPagination(Pagination<Lang> pagination, Lang lang) {
		PaginationHelper.prepare(pagination);
		return PaginationHelper.execute(langDao.selectLangForPagination(lang));
	}

	@Override
	@EhCacheable(key = "selectLangContentByKey")
	public Lang selectLangContentByKey(String langKey, String langType) {
		return langDao.selectLangContentByKey(langKey, langType);
	}

}
